using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;
namespace BUS
{
   public class tbLienketBUS
    {
        public static void Insert(tbLienket lk)
        {
            tbLienketDAL lkDAL = new tbLienketDAL();
            lkDAL.Insert(lk);
        }
        public static void Update(tbLienket lk)
        {
            tbLienketDAL lkDAL = new tbLienketDAL();
            lkDAL.Update(lk);
        }
        public static void Delete(int iD)
        {
            tbLienketDAL lkDAL = new tbLienketDAL();
            lkDAL.Delete(iD);
        }
        public static tbLienketCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbLienketDAL lkDAL = new tbLienketDAL();
            return lkDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbLienketCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLienketDAL lkDAL = new tbLienketDAL();
            return lkDAL.Get(cri.Criter, 0, 0, tbLienketColumn.Malienket.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbLienket GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbLienketColumn.Malienket.ToString(), Condition.EQUAL, iD);
            tbLienketDAL lkDAL = new tbLienketDAL();
            tbLienketCollection lkCollection = lkDAL.Get(cri.Criter, 0, 0, tbLienketColumn.Malienket.ToString(), OrderDirection.ASC.ToString(), out total);
            if (lkCollection.Count > 0)
                return lkCollection[0];
            return null;
        }
        public static tbLienketCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLienketDAL lkDAL = new tbLienketDAL();
            return lkDAL.Get(cri.Criter, 1, number,
            tbLienketColumn.Malienket.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbLienketCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLienketDAL lkDAL = new tbLienketDAL();
            return lkDAL.Get(cri.Criter, 1, number,
            tbLienketColumn.Malienket.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
